<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use Auth;
use DB;
class UserController extends Controller
{
    /**
     * 响应对 GET /users 的请求
     */
    public function getIndex()
    {
        //
    }

     /**
     * 响应对 GET /user/delcat/1 的请求
     */
    public function getDelcat($id)
    {
        //伪删除
        if(DB::table('cats')->where('pid',$id)->first()){          
           echo 0;
           die();
        }
        
        $cat['del']=2;

        if(DB::table('cats')->where('id',$id)->update($cat)){
            $data = 1;
        }
        echo $data;
    }

    /**
     * 响应对 GET /user/deluser/1 的请求
     */
    public function getDeluser($id)
    {
        //伪删除
        $user['updated_at']=date('Y-m-d H:i:s');
        $user['del']=2;
        if(DB::table('users')->where('id',$id)->update($user)){
            $data = 1;
        }
        echo $data;
    }

     /**
     * 响应对 GET /user/start/1 的请求
     * 用户启动
     */
    public function getStart($id)
    {
        $user['updated_at']=date('Y-m-d H:i:s');
        $user['status']=1;
        if(DB::table('users')->where('id',$id)->update($user)){
            $data = 1;
        }
        echo json_encode($data);

    }

    /**
     * 响应对 GET /user/stop/1 的请求
     * 用户停用
     */
    public function getStop($id)
    {
        $user['updated_at']=date('Y-m-d H:i:s');
        $user['status']=2;
        if(DB::table('users')->where('id',$id)->update($user)){
            $data = 1;
        }{
            $data = 0;
        }
        echo json_encode($data);

    }
    /**
     * 响应对 POST /users/profile 的请求
     */
    public function postProfile()
    {
        //
    }

    public  function  getUser()
    {
        dd(Auth::user());

        //dd(Auth::check());

    }
    public function  getLogout()
    {
        Auth::logout();
        return redirect('/auth/login');
    }
}
